package mc0101.mccache.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class ZcDistributedQueueApi {
//    @Autowired
//    private JedisCluster jedisCluster;
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public Long add(String key, String... value){
        //return jedisCluster.lpush(key, value);
        return redisTemplate.opsForList().leftPushAll(key, value);
    }

    public String take(String key){
        //return jedisCluster.rpop(key);
        return redisTemplate.opsForList().rightPop(key);
    }

    public Long getLength(String key){
        //return jedisCluster.llen(key);
        return redisTemplate.opsForList().size(key);
    }
}